package com.corechina.apex_osswords.domain.dao;

import com.corechina.apex_osswords.domain.entity.CoreServiceEngineer;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 * 服务对象--联系人表 Mapper 接口
 * </p>
 *
 * @author fyh
 * @since 2023-02-20
 */
@Component
public interface CoreServiceEngineerMapper extends BaseMapper<CoreServiceEngineer> {

    @Select("select count(1) from core_service_engineer where service_id = #{serviceId} and engineer_id = #{engineerId}")
    int checkEngineer(@Param("serviceId") Integer serviceId, @Param("engineerId") Integer engineerId);

    @Delete("delete from core_service_engineer where service_id = #{serviceId} and engineer_id = #{engineerId}")
    int deleteEngineer(@Param("serviceId") Integer serviceId, @Param("engineerId") Integer engineerId);

    @Select("select count(1) from core_service_engineer cse left join core_service_object cso on cso.id = cse.service_id where cse.engineer_id = #{engineerId} and cso.enterprise_id = #{enterpriseId}")
    int checkCount(@Param("engineerId") Integer engineerId, @Param("enterpriseId") Integer enterpriseId);

}
